/**
 * 55.跳跃游戏
 */
public class Exerciser8 {
    public boolean canJump(int[] nums) {
        int n = nums.length;
        int left = 0,right = 0;
        int ret = 0;
        int maxPos = 0;
        while(left <= right) {
            if(maxPos >= n - 1) {
                return true;
            }
            for(int i = left;i <= right;i++) {
                maxPos = Math.max(maxPos,nums[i] + i);
            }
            left = right + 1;
            right = maxPos;
        }
        return false;
    }
}
